<?php include_once('../control/page_top.php');?>
var productlist_loadcount=0;
$(document).ready(function(){
	$(window).scroll(function(){
		if(isScrolledIntoView('#product'+productlist_loadcount)){
			//alert('run in');
			productlist_getcontent();
			productlist_loadcount++;
		}
	});
});
function productlist_getcontent(){
	//LV2	
	tmp=parseInt(productlist_loadcount)+1;
	$.get("product.php", {id:tmp}, function(data){
		if($.trim(data)!='')
			$("#productlist").append(data);
	});
}
function isScrolledIntoView(elem)
{
	//LV3
	//$('#debug').html(elem);
	if($(elem).length > 0){
	    var docViewTop = $(window).scrollTop();
	    var docViewBottom = docViewTop + $(window).height();
	
	    var elemTop = $(elem).offset().top;
	    var elemBottom = elemTop + $(elem).height();
	
		return ( (elemTop <= docViewBottom));
	}else{
		return false;
	}
    
	//return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
    /*return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom)
      && (elemBottom <= docViewBottom) &&  (elemTop >= docViewTop) );*/
}